<template>
	<div class="bg-white">
		<div class="p-3 shadow rounded w-100">
			<Form ref="viptype" :label-width="100">
				<Row class="w-100">
					<Col :xxl="12" :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
						<FormItem class="" label="会员类型编号" prop="viptypeid">
							<Input v-model="viptype.viptypeid" placeholder="请输入会员类型编号"></Input>
						</FormItem>
					</Col>
					<Col :xxl="12" :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
						<FormItem class="" label="会员类型名称" prop="name">
							<Input v-model="viptype.name" placeholder="请输入会员类型名称"></Input>
						</FormItem>
					</Col>
					<Col :xxl="12" :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
						<FormItem class="" label="会员分钟" prop="minuts">
							<Input v-model="viptype.minuts" placeholder="请输入会员分钟"></Input>
						</FormItem>
					</Col>
					<Col :xxl="12" :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
						<FormItem class="" label="价格" prop="price">
							<Input v-model="viptype.price" placeholder="请输入价格"></Input>
						</FormItem>
					</Col>
					<Col :xxl="12" :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
						<FormItem class="w-50" label="状态">
							<Select v-model="viptype.statu">
								<Option value="1">上架</Option>
								<Option value="0">下架</Option>
							</Select>
						</FormItem>
					<!-- <FormItem class="" label="状态">
						<input type="radio" id="up" value="1" v-model="viptype.statu">
						<label for="up">上架</label>
						<input type="radio" id="down" value="0" v-model="viptype.statu">
						<label for="down">下架</label>
					</FormItem> -->
					</Col>
					
				</Row>
				<FormItem class="text-right">
					<Button @click="submit" type="primary">保存</Button>
				</FormItem>
			</Form>
		</div>
		
	
	</div>
	
</template>

<script>
	export default {
		data() {
			return {
				viptype: {
					viptypeid: "",
					name: "",
					minuts: "",
					price: "",
					statu: 1,
					
				}
			}
		},
		props: {
			params: {
				type: Object,
				default: undefined,
			}
		},
		methods: {
			submit: function() {
				var accountTest = /^[a-zA-Z0-9_-]{4,16}$/;
				var telTest = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
				if (this.viptype.viptypeid === "") {
					this.message.error("请输入会员类型编号");
					return;
				} else if (!accountTest.test(this.viptype.viptypeid)) {
					this.message.error("会员类型编号格式错误");
					return;
				}
				
				if (this.viptype.name === "") {
					this.message.error("请输入会员类型名称");
					return;
				}
				
				if (this.viptype.minuts === "") {
					this.message.error("请输入会员分钟");
					return;
				}
				
				if (this.viptype.price === "") {
					this.message.error("请输入价格");
					return;
				} 
				
				if (this.viptype.statu.length === 0) {
					this.message.error("状态必须选择");
					return;
				}
				
				
				
				this.message.confirm({
					title: "保存提示",
					content: "即将新增会员类型，确定吗？",
					onOk: () => {
						this.http.post({
							url: "/hyt/info",
							param: {
								viptype: JSON.stringify(this.viptype)
								
							}
						}).then(res => {
							this.message.info("新增成功");
							this.$router.detail.close();
						});
					},
					onCancel: () => {
						this.message.info('操作已取消');
					}
				});
			},
		},
		created: function() {
			this.viptype.statu = 0
		}
	}
</script>

<style scoped>
	
</style>
